package com.adaxi.adc.business.manager.controller;

import com.adaxi.adc.business.manager.pojo.VehicleTrip;
import com.adaxi.adc.business.manager.pojo.VehicleTripLocation;
import com.adaxi.adc.business.manager.service.VehicleTripLocationService;
import com.adaxi.adc.business.manager.service.VehicleTripService;
import com.adaxi.adc.business.manager.vo.VehicleTripVo;
import com.adaxi.adc.common.common.CommonResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Api(value = "行程订单查询",tags = "行程订单查询")
@RestController
public class VehicleTripController {
    /*
    司机行程状态查询
     */
    @Autowired
    VehicleTripService vehicleTripService;
    @Autowired
    VehicleTripLocationService vehicleTripLocationService;
@GetMapping(value = "/vehicleTrip")
@ApiOperation(value = "司机行驶状态查询",notes = "司机行驶状态查询")
public CommonResult queryVehicleTrip (){

List<VehicleTrip> list=vehicleTripService.list();
return CommonResult.SUCCESS("司机行驶状态查询成功",list);

}
    @GetMapping(value = "/queryByPage")
    @ApiOperation(value = "司机和行驶路线两表联查",notes = "司机和行驶路线两表联查")
    public CommonResult queryByPage (){
       List<VehicleTripVo> vo=vehicleTripService.queryByPage();
        return CommonResult.SUCCESS("司机行驶状态查询成功",vo);

    }
    @PostMapping(value = "/vehicleTrip/queryCondition")
    @ApiOperation(value = "查找",notes = "查找某条司机行程")
    public CommonResult queryCondition(@RequestBody VehicleTrip vehicleTrip){
        QueryWrapper<VehicleTrip> wrapper= Wrappers.query(vehicleTrip);
        List<VehicleTrip> list=vehicleTripService.list(wrapper);
        return CommonResult.SUCCESS("多条件查询成功" ,list);
    }
    /*
    根据id再查一遍
     */
    @GetMapping(value = "/queryById/{id}")
    @ApiOperation(value = "根据id查询经起始经纬度",notes = "根据id查询经纬度")
    public CommonResult queryById (@PathVariable("id") Long id ){
          VehicleTrip vehicleTrip= vehicleTripService.getById(id);

          return CommonResult.SUCCESS("查询成功",vehicleTrip);

    }
    @GetMapping(value = "/VehicleTripLocationById/{id}")
    @ApiOperation(value = "根据id查询司机当前经纬度",notes = "根据id查询经纬度")
    public CommonResult VehicleTripLocationById (@PathVariable("id") Long id ){
        VehicleTripLocation vehicleTripLocation=vehicleTripLocationService.getById(id);

        return CommonResult.SUCCESS("查询成功",vehicleTripLocation);

    }


}
